
#ifndef ZHOUBIAN_UI_H
#define ZHOUBIAN_UI_H

#include <QWidget>
#include <QtWidgets>
#include "ip_port.h"
#include "shoppingcart_ui_logic.h"
#include<QMouseEvent>

class ProductWidget : public QWidget
{
    Q_OBJECT
public:
    explicit ProductWidget(QWidget *parent = nullptr);

    void setEvent(const QPixmap &image,
                  const QString &Title,
                  const QString &price,
                const QString &description,
                  int productId);
    ~ProductWidget();

private:
    int productId;
    QLabel *imageLabel;
    QLabel *titleLabel;
    QLabel *priceLabel;
    QLabel *descriptionLabel;
    QPushButton *buyButton;
    QVBoxLayout *mainLayout;  // 使用垂直布局
    void mousePressEvent(QMouseEvent *event);
    void setupUi();

signals:
    void buyButtonClicked(const QString &title, const QString &price, int productId); // 添加信号
     void productClicked(const QPixmap &image, const QString &title, const QString &price, const QString &description, int productId);

private slots:
    void onBuyButtonClicked(); // 按钮点击事件
};

#endif // ZHOUBIAN_UI_H

